﻿package com.sgcc.nfc.lock.data.remote.api

import com.sgcc.nfc.lock.core.network.ApiResponse
import com.sgcc.nfc.lock.data.remote.dto.PagedDataDto
import com.sgcc.nfc.lock.data.remote.dto.room.RoomDto
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

interface RoomApi {

    @GET("/api/v1/room/list")
    suspend fun getRooms(
        @Query("pageNum") pageNum: Int,
        @Query("pageSize") pageSize: Int,
        @Query("regionId") regionId: Long? = null,
        @Query("keyword") keyword: String? = null
    ): ApiResponse<PagedDataDto<RoomDto>>

    @GET("/api/v1/room/{roomId}")
    suspend fun getRoomDetail(
        @Path("roomId") roomId: Long
    ): ApiResponse<RoomDto>

    @POST("/api/v1/room/add")
    suspend fun createRoom(
        @Body request: RoomRequest
    ): ApiResponse<Unit>

    @PUT("/api/v1/room/edit/{roomId}")
    suspend fun updateRoom(
        @Path("roomId") roomId: Long,
        @Body request: RoomRequest
    ): ApiResponse<Unit>

    @DELETE("/api/v1/room/delete/{roomId}")
    suspend fun deleteRoom(
        @Path("roomId") roomId: Long
    ): ApiResponse<Unit>
}

data class RoomRequest(
    val roomName: String,
    val regionId: Long,
    val longitude: Double,
    val latitude: Double,
    val address: String?
)
